#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=1050;
struct node{
    int id;
    int x;
    int y;
}points[3*MAXN];
bool cmp(node a,node b){
    if(a.x!=b.x){
        return a.x<b.x;
    }
    else{
        return a.y<b.y;
    }
}
int main(void){
    int t,n;
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        for(int i=0;i<3*n;i++){
            scanf("%d%d",&points[i].x,&points[i].y);
            points[i].id=i+1;
        }
        sort(points,points+3*n,cmp);
        for(int i=0;i<n;i++){
            printf("%d %d %d\n",points[3*i+0].id,points[3*i+1].id,points[3*i+2].id);
        }
    }
    return 0;
}
